<?php

namespace common\models;

use Yii;
use yii\behaviors\TimestampBehavior;

/**
 * This is the model class for table "{{%course}}".
 *
 * @property integer $id
 * @property string $title
 * @property integer $pid
 * @property string $price
 * @property integer $sort
 * @property integer $created_at
 * @property integer $updated_at
 */
class Course extends \yii\db\ActiveRecord
{
    /**
     * @inheritdoc
     */
    public static function tableName()
    {
        return '{{%course}}';
    }

    // 行为
    public function behaviors()
    {
        return [
          [ 'class' => TimestampBehavior::className()]
        ];
    }

    /**
     * @inheritdoc
     */
    public function rules()
    {
        return [
            [['title', 'price'], 'required'],
            [['pid', 'sort'], 'integer'],
            [['title', 'price', 'thumb'], 'string', 'max' => 255],
        ];
    }

    /**
     * @inheritdoc
     */
    public function attributeLabels()
    {
        return [
            'id' => 'ID',
            'title' => '课程名称',
            'thumb' => '缩略图',
            'pid' => '栏目',
            'price' => '价格',
            'sort' => '排序',
            'created_at' => '添加时间',
            'updated_at' => '更新时间',
        ];
    }
}
